import React, { Suspense } from 'react'
import { useRoutes, Navigate } from 'react-router-dom'

const UploadWeb = React.lazy(() => import('../views/upload-web'))
const UploadWebAdmin = React.lazy(() => import('../views/upload-web-admin'))
const UploadWebOss = React.lazy(() => import('../views/upload-web-oss'))

const Layout = React.lazy(() => import('../layout'))

export const routes = [{
  path: '/upload',
  element: <Layout><UploadWeb></UploadWeb></Layout>
},{
  path: '/upload/admin',
  element: <Layout><UploadWebAdmin></UploadWebAdmin></Layout>
},{
  path: '/upload/oss',
  element: <Layout><UploadWebOss></UploadWebOss></Layout>
}, {
  path: '/',
  element: <Navigate to="/upload"></Navigate>
}]

const Router = () => {
  const RouterView = () => useRoutes(routes)
  return <Suspense>
    <RouterView></RouterView>
  </Suspense>
}

export default Router